Public Sub RayTraceable_DrawBackfacesRemoved(ByVal pic As PictureBox)
RayTraceable_DrawWireFrame pic
End Sub
' Return the red, green, and blue components of
' the surface at the hit position.
Public Sub RayTraceable_FindHitColor(ByVal depth As Integer, Objects As Collection, ByVal eye_x As Single, ByVal eye_y As Single, ByVal eye_z As Single, ByVal px As Single, ByVal py As Single, ByVal pz As Single, ByRef R As Integer, ByRef G As Integer, ByRef B As Integer)
Public Sub RayTraceable_CullScanline(ByVal px As Single, ByVal py As Single, ByVal pz As Single, ByVal Nx As Single, ByVal Ny As Single, ByVal Nz As Single)
' Do not scanline cull.
DoneOnThisScanline = False
End Sub
' Return the value T for the point of intersection
' between the vector from point (px, py, pz) in
' the direction <vx, vy, vz>.
'
' direct_calculation is true if we are finding the
' intersection from a viewing position ray. It is
' false if we are finding an reflected intersection
' or a shadow feeler.
Public Function RayTraceable_FindT(ByVal direct_calculation As Boolean, ByVal px As Single, ByVal py As Single, ByVal pz As Single, ByVal Vx As Single, ByVal Vy As Single, ByVal Vz As Single) As Single
Dim A As Single
Dim B As Single
Dim C As Single
Dim D As Single
Dim Nx As Single
Dim Ny As Single
Dim Nz As Single
Dim denom As Single
Dim t As Single
Dim Cx As Single
Dim Cy As Single
Dim Cz As Single
Dim dx As Single
Dim dy As Single
Dim dz As Single
Dim X As Single
Dim Y As Single
Dim Z As Single
Dim checker_x As Single
Dim checker_y As Single
' See if we have been culled.
If direct_calculation And DoneOnThisScanline Then
RayTraceable_FindT = -1
Exit Function
End If
' Find the unit normal at this point.
GetUnitNormal Nx, Ny, Nz
' Compute the plane's parameters.
A = Nx
B = Ny
C = Nz
D = -(Nx * Point1.Trans(1) + _
Ny * Point1.Trans(2) + _
Nz * Point1.Trans(3))
' If the denominator = 0, the ray is parallel
' to the plane so there's no intersection.
denom = A * Vx + B * Vy + C * Vz
If denom = 0 Then
RayTraceable_FindT = -1
Exit Function
End If
' Solve for t.
t = -(A * px + B * py + C * pz + D) / denom
' If there is no positive t value, there's no
' intersection in this direction.
If t < 0.01 Then
RayTraceable_FindT = -1
Exit Function
End If
' Get the point of intersection with the plane.
X = px + t * Vx
Y = py + t * Vy
Z = pz + t * Vz
' See if the point is on a square.
If GetCheckerboardCoordinates(checker_x, checker_y, X, Y, Z) Then
' The point is on a square.
' We had a hit.
If direct_calculation Then HadHit = True
RayTraceable_FindT = t
Else
' The point is not on a square.
RayTraceable_FindT = -1
End If
End Function
' Return the minimum and maximum distances from
' this point.
' Use the wireframe points.
Private Sub RayTraceable_GetRminRmax(new_min As Single, new_max As Single, ByVal X As Single, ByVal Y As Single, ByVal Z As Single)